package oo2;

public class JavaClass {
	// 班级名称，指导老师，开班日期
	String clsName, dirTeacher, beginDate;
	// 存放学生信息
	String stus[] = new String[30];

	public void add(String name) {
		for (int i = 0; i < stus.length; i++) {
			if (stus[i] == null) {
				stus[i] = name;
				System.out.println(name + " 安排在" + (i + 1) + "位置");
				return;
			}
		}
		System.out.println("人员已满，无法加入");
	}

	public void showNames() {
		for (int i = 0; i < stus.length; i++) {
			if (stus[i] != null)
				System.out.print(stus[i] + " ");
			else
				break;
		}
		System.out.println();
	}

	// 能根据姓名，查找学生是否在此班级
	public boolean find(String name) {
		for (int i = 0; i < stus.length; i++) {
			if (stus[i] != null && stus[i].equals(name)) {
				// System.out.print(name + " 在数组中");
				return true;
			}
		}
		// System.out.println("不在");
		return false;
	}

	// 根据范围查找
	public boolean findRange(int start, int end, String name) {
		for (int i = start; i <= end; i++) {
			if (name.equals(stus[i])) {
				return true;
			}
		}
		return false;
	}
}
